﻿Type=Activity
Version=6
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.

	Private btnleft As Label
	Private ivfail As ImageView
	Private ivother As ImageView
	Private ivvictory As ImageView
	Private lblotherename As Label
	Private lblprice1 As Label
	Private lblprice2 As Label
	Private lblprice3 As Label
	Private lblprice4 As Label
	Private lblprice5 As Label
	Private lblprice6 As Label
	Private pb1 As ProgressBar
	Private pb2 As ProgressBar
	Private pb3 As ProgressBar
	Private pb4 As ProgressBar
	Private pb5 As ProgressBar
	Private pb6 As ProgressBar
	Private ivmylogo As ImageView
	Private lstData As List
	Type priceobj(colroot_data_big_money As String,colroot_data_last_time As Object,colroot_data_small_money As String,colroot_data_middle_money As String,colroot_data_id As String,colroot_data_title As String,colroot_data_is_tui As String,colroot_data_add_time As String,colroot_data_url As String,colroot_data_content As String,colroot_data_status As String)
	Dim tmrresult As Timer
	Private btncompare As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
	'Do not forget to load the layout file created with the visual designer. For example:
	Dim telaw As telanywhere
	telaw.Initialize(Activity)
	Activity.LoadLayout("laycompareprice")
	showresult(False)
	comm.setFA(btnleft,"fa-angle-left","")
	ProgressDialogShow2("正在获取最新价格数据",False)
	lstData.Initialize
	ParseHelper.doGetReq(Me,"getpricelist",comm.getApi(-1)&"app/qita/bijia",Null)
	comm.loadimground(comm.getApi(-1)&"icon.png",ivmylogo,0xFFEEB031,1dip)
End Sub
Sub showresult(isshow As Boolean)
	ivvictory.Visible=isshow
	ivfail.Visible=isshow
	SetRotate(pb1,180)
	SetRotate(pb3,180)
	SetRotate(pb5,180)
	lblprice1.Visible=isshow
	lblprice2.Visible=isshow
	lblprice3.Visible=isshow
	lblprice4.Visible=isshow
	lblprice5.Visible=isshow
	lblprice6.Visible=isshow
	
End Sub
Sub JobDone(thj As HttpJob)
	ProgressDialogHide
	If thj.Success Then
		Dim str As String=thj.GetString
		Dim nr As netRes=ParseHelper.getStatusData(str)
		If nr.nCode=200 Then
			Dim parser As JSONParser 
			parser.Initialize(str) 
			Dim root As Map = parser.NextObject 
			Dim data As List= root.Get("data") 
			lstData.Clear
			For Each coldata As Map In data 
			    Dim big_money As String = coldata.GetDefault("big_money","") 
'			    Dim last_time As String = coldata.GetDefault("last_time","") 
			    Dim small_money As String = coldata.GetDefault("small_money","") 
			    Dim middle_money As String = coldata.GetDefault("middle_money","") 
'			    Dim id As String = coldata.GetDefault("id","") 
			    Dim title As String = coldata.GetDefault("title","") 
'			    Dim is_tui As String = coldata.GetDefault("is_tui","") 
'			    Dim add_time As String = coldata.GetDefault("add_time","") 
			    Dim url As String = coldata.GetDefault("url","") 
'			    Dim content As String = coldata.GetDefault("content","") 
'			    Dim status As String = coldata.GetDefault("status","") 
				Dim po As priceobj
				po.Initialize
				po.colroot_data_title=title
				po.colroot_data_middle_money=middle_money
				po.colroot_data_big_money=big_money
				po.colroot_data_small_money=small_money
				po.colroot_data_url=comm.combinPic(url)
				lstData.Add(po)
			Next 
		Else
			comm.TL("获取价格数据出错:"&nr.sData)
			Activity.Finish
		End If
	Else
		comm.TL("网络错误:"&thj.ErrorMessage)
	End If
	thj.Release
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub ivback_Click
	Activity.Finish
End Sub

Sub btncompare_Click
	showresult(False)
	Dim lst As List
	lst.Initialize
	Dim po As priceobj
	For i=0 To lstData.Size-1
		po=lstData.Get(i)
		lst.Add(po.colroot_data_title)
	Next
	Dim ret As Int=InputList(lst,"选择要pk的对手",-1)
	If ret>-1 Then
		compareprice(ret)
		btncompare.Text="换一家试试"
	End If
	tmrresult.Initialize("showresult",1500)
	tmrresult.Enabled=True
	
End Sub
Sub showresult_Tick
	tmrresult.Enabled=False
	Dim ret As Int
	ret=Msgbox2($"要好老师，更要好价格！没有中间商赚差价！平均优惠30-50%！
    7*24小时家教热线：0991-2573888
天山区服务中心：人民路2号乌鲁木齐大厦四楼A座
新市区服务中心：鲤鱼山北路领世华府1号楼2112室"$,"试一下"&Application.LabelName&"吧！","家教热线","取消","网上预约",Null)
	If ret=DialogResponse.POSITIVE Then
		Dim pi As Intent
		pi.Initialize(pi.ACTION_VIEW,"tel:"&comm.S_CLIENTPHONENUMBER)
		StartActivity(pi)
	else if ret=DialogResponse.NEGATIVE Then
		CallSubDelayed(acthelpyoufindteacher,"nosub")
		Activity.Finish
	End If
End Sub
Sub compareprice(idx As Int)
	Dim po As priceobj=lstData.Get(idx)
	comm.loadimground(po.colroot_data_url,ivother,0xFFEEB031,1dip)
	lblotherename.Text=po.colroot_data_title
	lblprice4.Text=$"￥$1.0{po.colroot_data_small_money}元/次"$
	lblprice5.Text=$"￥$1.0{po.colroot_data_middle_money}元/次"$
	lblprice6.Text=$"￥$1.0{po.colroot_data_big_money}元/次"$
	showresult(True)
	setpro(pb1,150)
	setpro(pb3,260)
	setpro(pb5,320)
	setpro(pb2,po.colroot_data_small_money)
	setpro(pb4,po.colroot_data_middle_money)
	setpro(pb6,po.colroot_data_big_money)
End Sub
Sub SetRotate(n As View, Degrees As Double)
 	Dim ap As AnimationPlus
	ap.InitializeRotateCenter("rot",0,180,n)
	ap.PersistAfter=True
	ap.RepeatCount=0
	ap.Start(n)
End Sub
Sub rot_AnimationEnd
	
End Sub
Sub setpro(pb As ProgressBar,val As Int)
	Dim nval As Int=val
	pb.Progress=nval/10
End Sub


Sub ivother_Click
	btncompare_Click
End Sub